package com.sd.coupon.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sd.coupon.entity.Goods;
import com.sd.coupon.model.req.GoodsPageReq;
import com.sd.coupon.model.req.GoodsReq;
import com.sd.coupon.service.IGoodsService;
import com.sd.coupon.util.rest.RestResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
public class GoodsController {

    @Resource
    IGoodsService goodsService;

    @RequestMapping(value = "/goodsList", method = RequestMethod.POST)
    @ResponseBody
    public RestResponse getList(@RequestBody GoodsPageReq req) {
        IPage<Goods> res = goodsService.getGoodsPage(req);
        return RestResponse.success(res);
    }

    @RequestMapping(value = "/goods", method = RequestMethod.POST)
    @ResponseBody
    public RestResponse getOne(GoodsReq req) {
        Goods res = goodsService.getGoods(req);
        return RestResponse.success(res);
    }


}
